﻿@{
    Layout = null;
}

<!DOCTYPE html>
<html>
@Html.Partial("LoadPanelPartial")
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=7" />
    <title>SoftwareEntryUpload</title>
    @if (false)
    {
        <script src="../../../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>
        <script src="../../../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>
    }
    <link href="@Url.Content("~/Content/Site.css", true)" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>
        <script src="@Url.Content("~/Scripts/FloatDiv.js", true)" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/PageCommon.js", true)" type="text/javascript"></script>
     <script src="@Url.Content("~/Scripts/json2.js", true)" type="text/javascript"></script>

     <script src="@Url.Content("~/Fckeditor/fckeditor.js", true)" type="text/javascript"></script>
     <script src="@Url.Content("~/Common/GetRootPath.ashx", true)" type="text/javascript"></script>


     <link href="@Url.Content("~/Content/mediaUpLoad.css", true)" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/SWFUpload/js/swfupload.js", true)" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/SWFUpload/js/swfupload.swfobject.js", true)" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/SWFUpload/js/swfupload.queue.js", true)" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/SWFUpload/js/fileprogress.js", true)" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/SWFUpload/js/software_handlers.js", true)" type="text/javascript"></script>


     <script type="text/javascript">
         var swfu;

         SWFUpload.onload = function () {

             var settings = {

                flash_url: rootPath+"/Scripts/SWFUpload/swf/swfupload.swf",
                upload_url: "@ViewData["upload_url"]",
                file_size_limit: "@ViewData["file_size_limit"]",
                file_types: "@ViewData["file_types"]",
                file_types_description: "@ViewData["file_types"]",
                file_upload_limit: "@ViewData["file_upload_limit"]",
                file_queue_limit: 0,
                custom_settings: {
                    progressTarget: "fsUploadProgress",
                    cancelButtonId: "btnCancel",
                    uploadButtonId: "btnUpload",
                    myFileListTarget: "idFileList"
                },
                debug: false,
                auto_upload: false,
                //use_query_string:false,
                //post_params:{"tt":"1234"},
                // Button Settings
                button_image_url: "@ViewData["button_image_url"]",   // Relative to the SWF file   
                button_placeholder_id: "spanButtonPlaceholder",
                button_width: 61,
                button_height: 22,

                // The event handler functions are defined in handlers.js   
                swfupload_loaded_handler: swfUploadLoaded,
                //file_queued_handler: fileQueued,
                file_queued_handler: fileQueuedEvent, //自己增加的事件执行方法，默认为上一句代码!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                file_queue_error_handler: fileQueueError,
                //file_dialog_complete_handler: fileDialogComplete,
                file_dialog_complete_handler: fileDialogCompleteEvent, //自己增加的事件执行方法，默认为上一句代码!!!!!!!!!!!!!!!!!!!!!!!!!!!
                upload_start_handler: uploadStart,
                upload_progress_handler: uploadProgress,
                upload_error_handler: uploadError,
                upload_success_handler: uploadSuccess,
                upload_complete_handler: uploadComplete,
                queue_complete_handler: queueComplete, // Queue plugin event   

                // SWFObject settings   
                minimum_flash_version: "9.0.28",
                swfupload_pre_load_handler: swfUploadPreLoad,
                swfupload_load_failed_handler: swfUploadLoadFailed
            };


             swfu = new SWFUpload(settings);
         }


         function UploadFile() {
             swfu.startUpload();
         }



         function fileQueuedEvent(file) {
             try {
                 var fileListID = this.customSettings.myFileListTarget;
                 FileProgress(file, fileListID, this);

                 var _dirid = $('#hidDirID').val();
                 if (_dirid != "0") //如果不是相册上传图片，判断当前目录下是否有存在相同的文件名称
                 {
                     existsFileName(file, fileListID, _dirid);
                 }

             } catch (ex) {
                 this.debug(ex);
             }
         }


         //判断名称是否存在
         function existsFileName(file, fileListID, _dirid) {
             $.ajax({
                 type: 'POST',
                 url: 'managerDocAjax.ashx',
                 data: { modestr: 'existsFileName', dirid: _dirid, filename: file.name },
                 success: function (result) {
                     if (result == "T") {
                         fileCancel(file, fileListID, "当前目录下已存在");
                         //alert(file.name + " 文件在当前目录下已存在,该文件已被取消!");
                     }
                 }
             });
         }

         function fileDialogCompleteEvent(selectedNum, queuedNum) {
             if (queuedNum > 0) {
                 var queuedCount = swfu.getStats().files_queued; //在上传队列中的文件数
                 var uploadsCount = swfu.getStats().successful_uploads; //已经上传成功的文件数
                 var cancelledCount = swfu.getStats().upload_cancelled; //退出上传的文件数

                 var fileListID = this.customSettings.myFileListTarget;
                 var count = queuedCount + uploadsCount + cancelledCount;
                 var _f, _f1;
                 for (var i = 0; i < count - 1; i++) {
                     _f = swfu.getFile(i);
                     if (_f.filestatus == -1) {
                         for (var j = i + 1; j < count; j++) {
                             _f1 = swfu.getFile(j);
                             if (_f1.filestatus == -1) {
                                 if (_f1.name == _f.name) {
                                     fileCancel(_f1, fileListID, "上传列表中已存在");
                                     //alert(_f1.name + " 文件在上传列表中已存在,该文件已被取消!");
                                 }
                             }
                         }
                     }
                 }
             }
         }


         function fileCancel(file, fileListID, _errInfo) {
             swfu.cancelUpload(file.id);
             var tr = document.getElementById(file.id);
             tr.style.color = "red";
             var bar = document.getElementById(file.id + "_bar");
             var errInfo = _errInfo;
             bar.parentNode.innerHTML = errInfo;
             var delObject = document.getElementById(file.id + "_del");
             delObject.parentNode.innerHTML = "&nbsp;";
             document.getElementById(fileListID + "Count").innerHTML = swfu.getStats().files_queued;
         }


    </script>

    <style type="text/css">
        #ifu
        {
            width: 549px;
            height: 198px;
        }
    </style>
</head>
<body bgcolor="#FCFCFC" topmargin="0px" leftmargin="10px" rightmargin="10px" scroll="yes">
    
        <table width="100%" cellspacing="4" cellpadding="4" border="0" bgcolor="#FCFCFC">
            <tr>
                <td class="DH1">
                    <table width="100%" cellspacing="4" cellpadding="4" border="0" bgcolor="#FCFCFC">
                        <tr>
                            <td class="DH2">
                                <strong>@ViewData["DesTitle"]</strong> </td>
                            <td class="DH2" align="right">
                            </td>
                        </tr>
                    </table>
                    <div id="content">
                        <form id="form1" enctype="multipart/form-data">
                        <span id="spanButtonPlaceholder"></span>
                        <table id="idFileList" class="uploadFileList">
                            <tr class="uploadTitle">
                                <td>
                                    <b>文件名</b></td>
                                <td>
                                    <b>文件大小</b></td>
                                <td width="100px">
                                    <b>状态</b></td>
                                <td width="35px">
                                    &nbsp;</td>
                            </tr>
                        </table>
                        等待上传 <span id="idFileListCount">0</span> 个 ，成功上传 <span id="idFileListSuccessUploadCount">0</span> 个
                        <br />
                        <br />
                        <div id="divSWFUploadUI" style="visibility: hidden;">
                        </div>
                        </form>
                    </div>
                    <noscript style="display: block; margin: 10px 25px; padding: 10px 15px;">
                        很抱歉，相片上传界面无法载入，请将浏览器设置成支持JavaScript。
                    </noscript>
                    <div id="divLoadingContent" class="content" style="background-color: #FFFF66; border-top: solid 4px #FF9966; border-bottom: solid 4px #FF9966; margin: 10px 25px; padding: 10px 15px; display: none;">
                        相片上传界面正在载入，请稍后...
                    </div>
                    <div id="divLongLoading" class="content" style="background-color: #FFFF66; border-top: solid 4px #FF9966; border-bottom: solid 4px #FF9966; margin: 10px 25px; padding: 10px 15px; display: none;">
                        相片上传界面载入失败，请确保浏览器已经开启对JavaScript的支持，并且已经安装可以工作的Flash插件版本。
                    </div>
                    <div id="divAlternateContent" class="content" style="background-color: #FFFF66; border-top: solid 4px #FF9966; border-bottom: solid 4px #FF9966; margin: 10px 25px; padding: 10px 15px; display: none;">
                        很抱歉，相片上传界面无法载入，请安装或者升级您的Flash插件。 请访问： <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank">Adobe网站</a> 获取最新的Flash插件。
                    </div>
                    <table width="90%" cellspacing="0" cellpadding="0" border="0"  ">
                        <tr>
                            <td colspan="2">
                                <input id="btnUpload" type="button" value="开始上传" class="btn" style="display:none" />&nbsp;
                                <input id="UploadFile" type="button" value="开始上传" class="btn" onclick="UploadFile()" />
                                <input id="btnCancel" type="button" value="取消全部上传" disabled="disabled" class="btn" />
                            </td>
                        </tr>
                    </table>
                    </div> </td>
            </tr>
        </table>


        @using (Html.BeginForm("", "", FormMethod.Post, new { id = "form1" }))
        {
        }
        <script>
            lp.Hide();
    </script>
</body>
</html>
